#ifndef ADDFRIENDWIDGET_H
#define ADDFRIENDWIDGET_H

#include <QWidget>
#include <QDialog>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QScrollArea>
#include <QScrollBar>
#include <QVBoxLayout>

#include "model/data.h"
#include "debug.h"

using model::UserInfo;

//////////////////////////////////
/// 一个搜索结果
//////////////////////////////////
class FriendResultItem : public QWidget
{
    Q_OBJECT
public:
    FriendResultItem(const UserInfo &userInfo);
private:
    UserInfo _userInfo;
    QGridLayout *_layout;
    QPushButton *_avatarBtn;
    QLabel *_nameLabel;
    QLabel *_descLabel;
    QPushButton *_addBtn;
};

//////////////////////////////////
/// 添加好友主界面
//////////////////////////////////
class AddFriendWidget : public QDialog
{
    Q_OBJECT
public:
    AddFriendWidget(QWidget *parent = nullptr);

    void setSearchKey(const QString &key);

    void addResult(const UserInfo &userInfo);
    void clear();

private:
    void initResultArea();

private:
    QGridLayout *_layout;
    QLineEdit *_searchEdit;
    QPushButton *_searchBtn;
    QScrollArea *_scrollArea;
    QWidget *_container;
    QVBoxLayout *_vlayout;
};

#endif // ADDFRIENDWIDGET_H
